# 713 中等：乘积小于K的子数组

def numSubarrayProductLessThanK(nums, k):
    ret = 0
    left, right = 0, 0
    num = 1

    while right < len(nums):
        num *= nums[right]
        while num >= k:
            num //= nums[left]
            left += 1
            if left == len(nums):
                return ret
        ret += right - left + 1
        right += 1

    print(ret, num, left, right)
    return ret


print(numSubarrayProductLessThanK([10, 5, 2, 6], 60))
